package com.coocaa.internship.dao;

import com.coocaa.internship.pojo.DeliverCv;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: 简历投递Dao层
 * @Author: zwh
 * @Date: 2019-07-27
 * @Time: 13:47
 */
@Mapper
@Component
public interface DeliverCvDao {
    String TABLE_NAME = "deliver_cv";
    String INSERT_FILEDS = "user_cv_id , company_id , position_id";
    String SELECT_FIELDS = "id , user_cv_id , company_id , position_id , deliver_time";

    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME, " where user_cv_id = #{userCvId}"})
    List<DeliverCv> selectDeliverCvByCvId(@Param("userCvId") Long userCvId);

    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME, " where user_cv_id = #{userCvId} and company_id = #{companyId}"})
    DeliverCv selectDeliverCvByCvIdAndCompanyId(DeliverCv deliverCv);

    @Insert({"insert into ", TABLE_NAME, " (", INSERT_FILEDS, ") values (#{userCvId},#{companyId},#{positionId})"})
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    Integer insertDeliverCv(DeliverCv deliverCv);

    @Delete({"delete from ", TABLE_NAME, " where user_cv_id = #{userCvId} and position_id = #{positionId}"})
    Integer deleteDeliverCvByCvId(Long userCvId, Long positionId);
}
